// =======================================================================
// 
//       Filename:  Element.hpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  20.04.2010 00:37:38
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dominik 'domachine' Burgdörfer (-), dominik.burgdoerfer@googlemail.com
//        Company:  -
// 
// =======================================================================

#ifndef  ELEMENT_INC
#define  ELEMENT_INC
#include <fstream>
#include "../types/object.hpp"

namespace webplodder {
    namespace Template {
        class File; // Forward Declaration

        class Element : public types::Object 
        {
            public:
                enum Type {
                    TEXT,
                    COMMAND,
                    VAR,
                    SCRIPT
                };

                Element(File& parent,
                        Type type);

                virtual ~Element();

                virtual Type elementType() const;

                virtual int line() const;

                virtual void setLine(int line);

                virtual void printTo(std::ostream& output);

                virtual bool operator>>(char& ch);

                virtual Element& operator<<(char ch);

                friend bool operator<<(char& ch, Element& element);

                friend Element& operator>>(char ch, Element& element);

            protected:
                virtual bool getChar(char& ch) = 0;

                File* mParent;
                Type mType;
                int mLine;

            private:
                std::string mBuffer;
                bool mCache;
                unsigned int mIndex;
        };
    }
}

bool operator<<(char& ch, webplodder::Template::Element& element);

webplodder::Template::Element& operator>>(char ch, 
                              webplodder::Template::Element& element);
#endif   // ----- #ifndef ELEMENT_INC  -----

